﻿/*
 * @Autor: PK
 * @Date: 2022/01/11 20:34:SS
 */

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using PropertyChanged;
using ShkSimulation.core.factory;
using ShkSimulation.desktop.Annotations;
using static ShkSimulation.carsharing.impl.create.RoadFactory;

namespace ShkSimulation.desktop.setting.model {

	[AddINotifyPropertyChangedInterface]
	public class RoadConfigModel: INotifyPropertyChanged {

		public RoadConfigModel() {
		}

		public RoadConfigModel(CreateParam param) {
			this.Id = Convert.ToInt32(param[RoadId]);
			this.Name = Convert.ToString(param[RoadName]);
			this.Capacity = Convert.ToDouble(param[RoadCapacity]);
			this.LastStationId = Convert.ToInt32(param[RoadLastStationId]);
			this.NextStationId = Convert.ToInt32(param[RoadNextStationId]);
			this.RoadLength = Convert.ToDouble(param[RoadDefaultLength]);
			this.FreeSpeed = Convert.ToDouble(param[RoadFreeSpeed]);
			//this.Utilization = Convert.ToDouble(param[RoadUtilization]);
			//this.ServiceDemandFactor = Convert.ToDouble(param[RoadServiceDemandFactor]);
			//this.PotentialDemand = Convert.ToDouble(param[RoadPotentialDemand]);
			//this.MaxPrice = Convert.ToDouble(param[RoadMaxPrice]);
			this.Price = Convert.ToDouble(param[RoadPrice]);
			this.FuelCost = Convert.ToDouble(param[RoadFuelCost]);
		}

		public RoadConfigModel(int id, int lastStationId, int nextStationId) {
			this.Id = id;
			this.Name = id.ToString();
			this.LastStationId = lastStationId;
			this.NextStationId = nextStationId;
		}

		public int Id { get; set; }
		public string Name { get; set; }
		public double Capacity { get; set; }
		public int LastStationId { get; set; }
		public int NextStationId { get; set; }
		public double RoadLength { get; set; }
		public double FreeSpeed { get; set; }
		public double Utilization { get; set; }
		public double ServiceDemandFactor { get; set; }
		public double PotentialDemand { get; set; }
		public double MaxPrice { get; set; }
		public double Price { get; set; }
		public double FuelCost { get; set; }

		public event PropertyChangedEventHandler PropertyChanged;

		[NotifyPropertyChangedInvocator]
		protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
			PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
		}

		public override string ToString() {
			return $"Id: {Id}, Name: {Name}, Capacity: {Capacity}, LastStationId: {LastStationId}, NextStationId: {NextStationId}, RoadLength: {RoadLength}, FreeSpeed: {FreeSpeed}, Utilization: {Utilization}, ServiceDemandFactor: {ServiceDemandFactor}, MaxPrice: {MaxPrice}, Price: {Price}, FuelCost: {FuelCost}";
		}

	}

}